<%@ page import="com.scalar.chiptrack.operations.lotcorrection.forms.LotCorrectionForm,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.operations.lotcorrection.LotCorrection" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>


<chiptrack:checkLogon sourcePage="/lotCorrection.do"/>

<% String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<%

    String closeWindowAfterSave	= (String) request.getAttribute( "CloseWindowAfterSave" );
    String[] selectedCsIds = ( String[] ) session.getAttribute( "selectedCSIds" );

%>
<HTML>
<HEAD>
<TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>

<SCRIPT language="JavaScript">
<% if ( ( closeWindowAfterSave != null ) && ( closeWindowAfterSave.equalsIgnoreCase( "true" ) ) ) { %>
	window.close();
<% } %>

var selectedCsIdsArray = new Array();

<%
    if ( selectedCsIds != null && selectedCsIds.length > 0 )
    {
        StringBuffer selectedIds =  new StringBuffer();
        for ( int i = 0; i < selectedCsIds.length; i++ )
        {
            selectedIds.append( "selectedCsIdsArray[" +  i  + "]=\"" + selectedCsIds[i] + "\";\n" );
        }
        out.println(selectedIds);
    }
%>

function submitForm()
{
    document.psLineItemForm.submit();
}
function onLoad()
{

    var chkBoxValue = "";
    if (typeof document.psLineItemForm.chkCsLineItemId != 'undefined' )
	{
        for( var j = 0 ; j < selectedCsIdsArray.length ; j++ )
        {
            if (typeof document.psLineItemForm.chkCsLineItemId.length == 'undefined' )
            {
                chkBoxValue = document.psLineItemForm.chkCsLineItemId.value;
                if( selectedCsIdsArray[j].toLowerCase().trim() == chkBoxValue )
                {
                    document.psLineItemForm.chkCsLineItemId.checked = true
                }
            }
            else
            {
                for( var i = 0 ; i < document.psLineItemForm.chkCsLineItemId.length; i++ )
                {
                    chkBoxValue = document.psLineItemForm.chkCsLineItemId[i].value;
                    if( selectedCsIdsArray[j].toLowerCase().trim() == chkBoxValue )
                    {
                        document.psLineItemForm.chkCsLineItemId[i].checked = true
                    }
                }
            }
        }
    }
}

</SCRIPT>

</HEAD>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0"  onload="javascript:onLoad();">
<form name="psLineItemForm" method="post" action="lotCorrection.do?action=revertLotLineItemQty">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR>
        <TD>
            <table border="0" width="100%" bordercolor="#FFFFFF">
                <tr><td>&nbsp;</td></tr>
                <tr><td align="center"><font class="NArialW" color="#FFFFFF">Packing Slip Line Items</font></td></tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td>
                        <table border="0" width="100%" bordercolor="#FFFFFF">
                            <tr>
                                <td width="5%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Select</font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sales Order #</font></td>
                                <td width="20%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Packing Slip #</font></td>
                                <td width="12%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Generated Date</font></td>
                                <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item #</font></td>
                                <td width="20%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber"/></font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item Quantity Pulled</font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Lot Quantity Pulled</font></td>
                            </tr>
                            <logic:present name="PackingSlipsMap">
                                <logic:iterate id="psHashMap" name="PackingSlipsMap" >
                                    <bean:define id="psForm" name="psHashMap" property="value" type="com.scalar.chiptrack.operations.packingslip.forms.PackingSlipForm" />
                                    <bean:define id="psLineItems" name="psForm" property="lineitems" />
                                    <tr>
                                        <td align="center" bgcolor="#DEE1E2"><input type="checkbox" name="chkCsLineItemId" value="<bean:write name="psForm" property="customerShippingId"/>"/></td>
                                        <td align="center" bgcolor="#DEE1E2"><font class="NArialL"><bean:write name="psForm" property="salesOrderNumber"/></font></td>
                                        <td align="center" bgcolor="#DEE1E2"><font class="NArialL"><bean:write name="psForm" property="label"/></font></td>
                                        <td class="NArialL" align="center" bgcolor="#DEE1E2"><bean:write name="psForm" property="generatedDate"/></td>

                                        <td align="center" bgcolor="#DEE1E2">
                                            <table border="0" width="100%" bordercolor="#FFFFFF" cellSpacing="1" cellPadding="0">
                                            <logic:iterate id="psLineItemsList" name="psLineItems" type="com.scalar.chiptrack.operations.lotcorrection.PackingSlipLineItem">
                                                <tr bgcolor="#DEE1E2">
                                                    <td width="7%" align="center"><font class="NArialL"><bean:write name="psLineItemsList" property="lineItemNumber"/></font></td>
                                                </tr>
                                            </logic:iterate>
                                            </table>
                                        </td>
                                        <td align="center" bgcolor="#DEE1E2">
                                            <table border="0" width="100%" bordercolor="#FFFFFF" cellSpacing="1" cellPadding="0">
                                            <logic:iterate id="psLineItemsList" name="psLineItems" type="com.scalar.chiptrack.operations.lotcorrection.PackingSlipLineItem">
                                                <tr bgcolor="#DEE1E2">
                                                    <td width="20%" align="center" nowrap><font class="NArialL"><bean:write name="psLineItemsList"  property="partNumber"/></font></td>
                                                </tr>
                                            </logic:iterate>
                                            </table>
                                        </td>
                                        <td align="center" bgcolor="#DEE1E2">
                                            <table border="0" width="100%" bordercolor="#FFFFFF" cellSpacing="1" cellPadding="0">
                                            <logic:iterate id="psLineItemsList" name="psLineItems" type="com.scalar.chiptrack.operations.lotcorrection.PackingSlipLineItem">
                                                <tr bgcolor="#DEE1E2">
                                                    <td width="10%" align="center"><font class="NArialL"><bean:write name="psLineItemsList"  property="lineItemQtyPulled"/></font></td>
                                                </tr>
                                            </logic:iterate>
                                            </table>
                                        </td>
                                        <td align="center" bgcolor="#DEE1E2">
                                            <table border="0" width="100%" bordercolor="#FFFFFF" cellSpacing="1" cellPadding="0">
                                            <logic:iterate id="psLineItemsList" name="psLineItems" type="com.scalar.chiptrack.operations.lotcorrection.PackingSlipLineItem">
                                                <tr bgcolor="#DEE1E2">
                                                    <td width="10%" align="center"><font class="NArialL"><bean:write name="psLineItemsList"  property="lotQtyPulled"/></font></td>
                                                </tr>
                                            </logic:iterate>
                                            </table>
                                        </td>
                                    </tr>
                                </logic:iterate>
                            </logic:present>
                         </table>
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td align="center">
                        <a href="javascript:submitForm();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Save Lot Data';return true" onmouseout="window.status='';return true" title="Click here to Save Lot Data"></a>
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
            </table>
        </TD>
    </TR>
</TABLE>
</form>
</BODY>
</HTML>
